/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.dizucar.modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author 43579648
 */
@Entity
@Table(name = "VENTA", catalog = "", schema = "DIZUCAR")
@NamedQueries({
    @NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v"),
    @NamedQuery(name = "Venta.findByIdventa", query = "SELECT v FROM Venta v WHERE v.idventa = :idventa"),
    @NamedQuery(name = "Venta.findByFechaventa", query = "SELECT v FROM Venta v WHERE v.fechaventa = :fechaventa"),
    @NamedQuery(name = "Venta.findByNumerofactura", query = "SELECT v FROM Venta v WHERE v.numerofactura = :numerofactura")})
public class Venta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IDVENTA", nullable = false)
    private Integer idventa;
    @Basic(optional = false)
    @Column(name = "FECHAVENTA", nullable = false)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date fechaventa;
    @Basic(optional = false)
    @Column(name = "NUMEROFACTURA", nullable = false)
    private long numerofactura;
    @JoinColumn(name = "IDTIPOFACTURA", referencedColumnName = "IDTIPOFACTURA", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoFactura tipoFactura;
    @JoinColumn(name = "IDFORMAPAGO", referencedColumnName = "IDFORMAPAGO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private FormaPago formaPago;
    @JoinColumn(name = "IDCLIENTE", referencedColumnName = "IDCLIENTE", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cliente cliente;
    @JoinColumn(name = "IDTIENEDA", referencedColumnName = "IDTIENEDA", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Tienda tienda;
    @JoinColumn(name = "IDCAJERO", referencedColumnName = "IDCAJERO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cajero cajero;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venta", fetch = FetchType.LAZY)
    private List<Queja> quejaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venta", fetch = FetchType.LAZY)
    private List<DetalleVenta> detalleVentaList;

    public Venta() {
    }

    public Venta(Integer idventa) {
        this.idventa = idventa;
    }

    public Venta(Integer idventa, Date fechaventa, long numerofactura, String lugardespachi) {
        this.idventa = idventa;
        this.fechaventa = fechaventa;
        this.numerofactura = numerofactura;
    }

    public Integer getIdventa() {
        return idventa;
    }

    public void setIdventa(Integer idventa) {
        this.idventa = idventa;
    }

    public Date getFechaventa() {
        return fechaventa;
    }

    public void setFechaventa(Date fechaventa) {
        this.fechaventa = fechaventa;
    }

    public long getNumerofactura() {
        return numerofactura;
    }

    public void setNumerofactura(long numerofactura) {
        this.numerofactura = numerofactura;
    }

 

    public TipoFactura getTipoFactura() {
        return tipoFactura;
    }

    public void setTipoFactura(TipoFactura tipoFactura) {
        this.tipoFactura = tipoFactura;
    }

    public FormaPago getFormaPago() {
        return formaPago;
    }

    public void setFormaPago(FormaPago formaPago) {
        this.formaPago = formaPago;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public Cajero getCajero() {
        return cajero;
    }

    public void setCajero(Cajero cajero) {
        this.cajero = cajero;
    }

    public List<Queja> getQuejaList() {
        return quejaList;
    }

    public void setQuejaList(List<Queja> quejaList) {
        this.quejaList = quejaList;
    }

    public List<DetalleVenta> getDetalleVentaList() {
        return detalleVentaList;
    }

    public void setDetalleVentaList(List<DetalleVenta> detalleVentaList) {
        this.detalleVentaList = detalleVentaList;
    }

    public Tienda getTienda() {
        return tienda;
    }

    public void setTienda(Tienda tienda) {
        this.tienda = tienda;
    }




    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idventa != null ? idventa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Venta)) {
            return false;
        }
        Venta other = (Venta) object;
        if ((this.idventa == null && other.idventa != null) || (this.idventa != null && !this.idventa.equals(other.idventa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sv.com.dizucar.modelo.Venta[idventa=" + idventa + "]";
    }

}
